package vistor;

import java.util.LinkedList;
import java.util.List;

/**
 * @author shenhan
 * @create 2020/4/10 15:36
 * @description
 */
public class ObjectStructure {
    private List<Person> persons = new LinkedList<>();

    public void attach(Person person) {
        persons.add(person);
    }

    public void detach(Person person) {
        persons.remove(person);
    }

    public void display(Action action) {
        persons.forEach(p -> p.accept(action));
    }
}
